--火焰剥离
local huoyanboli = fk.CreateSkill {
    name = "mcdh_huoyanboli",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

huoyanboli:addEffect('active',{
    prompt = function (self, player,selected_cards, selected_targets)
        return "#mcdh_huoyanboli_active:::"..#player.player_cards[Player.Hand]
    end,
    card_filter = Util.FalseFunc,
    can_use = function(self, player)
        if player:usedSkillTimes(self.name) ~= 0 then
            return false
        end
        local cardsuit = {}
        for _, id in ipairs(player.player_cards[Player.Hand]) do
            local card = Fk:getCardById(id)
            table.insertIfNeed(cardsuit,card.suit)
            if #cardsuit > 1 then
                return false
            end
        end
        return #cardsuit == 1
    end,
    min_target_num = 1,
    target_filter = function(self, player,to_select, selected)
        if #selected == #player.player_cards[Player.Hand] then
            return false
        end
        local tem_player = to_select
        if tem_player then
            return player:canUseTo(Fk:cloneCard("fire__slash"),tem_player,{bypass_times = true})
        end
    end,
    on_use = function (self, room, effect)
        local player = effect.from
        player:showCards(player.player_cards[Player.Hand])
        room:delay(100)
        local slash = Fk:cloneCard("fire__slash")
        slash.skillName = self.name
        local use = {
            from = effect.from,
            tos = effect.tos,
            card = slash,
            extraUse = true,
        }
        use.extra_data = use.extra_data or {}
        use.extra_data.mcdh_huoyanboli = player.id
        room:useCard(use)
    end
})

huoyanboli:addEffect(fk.Death,{
    can_refresh = function(self, event, target, player, data)
        return target == player and data.damage and data.damage.card and table.contains(data.damage.card.skillNames, self.name)
    end,
    on_refresh = function(self, event, target, player, data)
        local room = player.room
        local use = room.logic:getMostRecentEvent(GameEvent.UseCard).data[1]
        local user = room:getPlayerById((use.extra_data or {}).mcdh_huoyanboli)
        user:setSkillUseHistory("mcdh_huoyanboli", 0, Player.HistoryTurn)
end,
})

Fk:loadTranslationTable {
    ["mcdh_huoyanboli"] = "爆裂",
    [":mcdh_huoyanboli"] = "出牌阶段限一次，若你的手牌花色均相同，你可以展示手牌，并视为使用一张不计入次数且无次数限制的目标数最多为X的火【杀】(X为你的手牌数)，若你以此法杀死了角色，本回合本技能视为未发动过。",
    ["#mcdh_huoyanboli_active"] = "爆裂：展示你的手牌，并选择至多 %arg 名攻击范围内的角色，视为对这些角色使用一张不计入次数且无次数限制的火【杀】"
}

return huoyanboli